



#ifndef AABB_H
#define AABB_H

#include <vector>
using std::vector;

#include <Vec4.h>

class Matrix4;
class Ray;

	
class Aabb
{
		
	public:
	
	Aabb()
	{
		reset();
	}
	
	// Put the AABB in a state ready to include points.
	void reset();
		
	// Update this AABB to include the given point.
	void includePoint(const Vec4& point);
	
	// Compute the AABB of the given vertices, overwriting this AABB.
	void compute( const vector<Vec4>& worldVerts );
	
	// Compute the union of this AABB with another one, overwriting this AABB.
	void add( const Aabb& aabbOther );
	
	// Intersection of this AABB with a given Ray
	bool intersectRay( const Ray& R, float& t_entryOut, float& t_exitOut ) const;
	
	// Expand this AABB uniformly by a specified factor
	void expand( float factor );
	
	// Transform this AABB by a specified transform
	void transform( const Matrix4& transform );
	
	// Get the total surface area of this AABB
	float surfaceArea( ) const;
	
	// Get the length of the largest edge
	float size() const;
	
	// Whether this AABB overlaps the other given one
	bool overlaps(const Aabb& other);
	
	// Debug draw
	void draw();
	

	Vec4 m_maxima;
	Vec4 m_minima;
	
	
};
	



#endif //AABB_H